const app = getApp();
var api = require('../../api.js');
var WxParse = require('../../wxParse/wxParse.js');
var mta = require('../../mta_analysis.js');

Page({
  data: {
    id: '',
    list: '',
    article: '',
  },
  onLoad: function (options) {
    console.log("————————————————测试————————————————");
    var that = this;
    console.log(options)
    let list = JSON.parse(options.str);
    console.log(list.id)
    that.setData({
      id: list.id,
    });
    mta.Page.init();
  },
  onReady: function () {
  
  },
  onShow: function () {
    this.getArticle();
  },
  onHide: function () {
    var url = app.getcurrentPageStr();
    wx.setStorageSync("from_url", url);
  },
  onUnload: function () {
  
  },
  onPullDownRefresh: function () {
  
  },
  onReachBottom: function () {
  
  },
  onShareAppMessage: function () {

    var url = app.getcurrentPageStr();
    var user_id = wx.getStorageSync('user_id');
    return {
      path: url + "&user_id=" + user_id,
      title: '得道1314'
    };
    
  },
  back: function (e) {
    wx.navigateBack({
      delta: 1
    })
  },
  // 获取基本信息
  getArticle: function (e) {
    var that = this;
    var access_token = wx.getStorageSync('access_token');
    var url = api.vipOrder.detail;
    var id = that.data.id;
    wx.request({
      url: url,
      method: "get",
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        access_token: access_token,
        id: id,
      },
      success: function (e) {
        console.log(e)
        console.log("————————————————————道财说明————————————————");
        
        var article = e.data.data.level_content;
        var temp = WxParse.wxParse('article1', 'html', article, that, 5);
        that.setData({
          article: temp,
        })
      }
    });
  }
})